
//妙购一卡通
var ecard = [
	{ "RFU": "", "RequestType": 37008 },                                                                                                                                                         //读卡信息
    {"OrderId": "", "TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "UseCoupon": 1, "Postage": 0.0, "PostagePayment": 0, "CreditsFlag": 1, "RFU": "", "RequestType": 4149 },       //订购预授权
    {'OrderId': '', 'TransAmt': 0.0, 'CAIC': '', 'TN': '', 'CATI': '', 'ApprovalCode': '', 'PIN': '', 'PRRN': '', 'PDate': '', 'RFU': '', 'RequestType': 12341 },                                //订购预授权取消
    {'OrderId': '', 'TransAmt': 0.0, 'CAIC': '', 'TN': '', 'CATI': '', 'PIN': '', 'UseCoupon': 1, 'Postage': 0.0, 'PostagePayment': 0, 'CreditsFlag': 1, 'RFU': '', 'RequestType': 21249 },      //订购预授权冲正
    {'OrderId': '', 'TransAmt': 0.0, 'CAIC': '', 'TN': '', 'CATI': '', 'ApprovalCode': '', 'OprFlag': 2, 'OrderDate': '', 'PIN': '', 'PRRN': '', 'PDate': '', 'RFU': '', 'RequestType': 4165 }, //订购预授权确认
    {"TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "OprFlag": 2, "PinData": "", "NameFlag": "N", "Name": "", "IdType": 1, "IdNum": "", "UF": 0, "RFU": "", "RequestType": 28933 },  //修改/重置PIN
    {"TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "UF": 0, "RFU": "", "RequestType": 29445 }, //PIN限额
    {"TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PinFlag": "Y", "PinData": "", "NameFlag": "Y", "Name": "", "IdType": 1, "IdNum": "", "Phone": "", "Email": "", "PostAddr": "", "PostCode": "", "UserId": "", "LoginId": "", "PinCheckAmt": 0.0, "BalNotice": 0.0, "RFU": "", "RequestType": 28677 }, //账户开通
    {"TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "PAN": "", "PinFlag": "Y", "PinData": "", "RFU": "", "RequestType": 28709 }, //附卡绑定主卡账户
    {"TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "CardNo": "", "CardStatus": "Y", "UF": 0, "RFU": "", "RequestType": 29717 }, //修改客户卡信息
    {"TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "IfReadCard": "Y", "CardNo": "", "LF": "Y", "UF": 0, "RFU": "", "RequestType": 29749 }, //验证账户信息
    {"TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "AttachCardNum": "", "UF": 0, "RFU": "", "RequestType": 28725 }, // 附卡解除绑定
    {"CAIC": "", "TN": "", "CATI": "", "RFU": "", "RequestType": 25093 }, //更新终端主密钥
    {"CAIC": "", "TN": "", "CATI": "", "RFU": "", "RequestType": 25125 }, //更新终端工作密钥
    {"SrvIp": "127.0.0.1", "SrvPort": 0, "SrvIpBak": "127.0.0.1", "SrvPortBak": 0, "COMX": "", "RFU": "", "RequestType": 32896 }, //通讯参数设置
    {"RFU": "", "RequestType": 32768 }, //获取设备信息
    {"SrvDomainName": "", "SrvPort": 0, "RFU": "", "RequestType": 32897 }, //设置清算中心域名
    {"RFU": "0", "RequestType": 39321 }, //清算线路测试,
    {"UptIp": "112.65.184.46", "UptPort": 41000, "RFU": "", "RequestType": 33280 }, //查询妙购服务程序版本
    {"TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "OrderId": "", "ItemId": "", "CreditsRFU": "", "Postage": 0.0, "PostagePayment": 0, "RFU": "", "RequestType": 4613 }, //积分消费
    {"TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "OrderId": "", "ItemId": "", "CreditsRFU": "", "Postage": 0.0, "PostagePayment": 0, "RFU": "", "RequestType": 20513 }, //积分消费冲正
    {"TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "OrderId_Origin": "", "RRN_Origin": "", "RFU": "", "RequestType": 12805 }, //积分消费撤销
    {"TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "OrderId_Origin": "", "RRN_Origin": "", "ApprovalCode": "", "AffirmDate": "", "RFU": "", "RequestType": 4629 }, //积分消费确认
    {"OrderId": "", "TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "BankFlag": "Y", "BankAccNo": "", "CardHolderName": "", "UF": 0, "RFU": "", "RequestType": 5173 }, //银行代扣请求
    {"OrderId": "", "TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "BankFlag": "Y", "BankAccNo": "", "CardHolderName": "", "UF": 0, "RFU": "", "RequestType": 5189 }, //银行代扣查询
    {"OrderId": "", "TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "BankAccNo": "", "Mobile": "", "BankCode": "", "Rsvd": "", "BankProvince": "", "BankCity": "", "BankName": "", "AccType": 1, "ExpireDate": "", "CVV": "", "TxnPIN": "", "PinCheckAmt": 0.0, "BalNotice": 0.0, "ExtNo": "", "AuthFlag": "Y", "Name": "", "IdType": 2, "IdNo": "", "AppendInfoFlag": "N", "Phone": "", "Email": "", "Address": "", "PostCode": "", "AppendTxnInfo": { "Length": 0, "AppendInfo": "" }, "RequestType": 33029 }, //银行代扣签约开户（申请）
    {"OrderId": "", "TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "BankAccNo": "", "Mobile": "", "BankCode": "", "Rsvd": "", "BankProvince": "", "BankCity": "", "BankName": "", "AccType": 1, "ExpireDate": "", "CVV": "", "AppendTxnInfo": { "Length": 0, "AppendInfo": "" }, "UF": 0, "RFU": "", "RequestType": 33045 }, //银行代扣签约（已开户）
    {"OrderId": "", "TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "BankFlag": "N", "BankAccNo": "", "CardHolderName": "", "UF": 0, "RFU": "", "RequestType": 33061 }, //银行代扣签约解除
    {"OrderId": "", "TransAmt": 0.0, "CAIC": "", "TN": "", "CATI": "", "PIN": "", "BankAccNo": "", "UF": 0, "RFU": "", "RequestType": 33077 }, //银行代扣签约查询
    {"UptIp": "", "UptPort": 0, "ReqVer": 0, "PktSize": 0, "SHA1": "", "FileName": "", "LocalPath": "", "RFU": "", "RequestType": 33281 }, //下载妙购服务程序更新包（8201）
    {"UptIp": "", "UptPort": 0, "RFU": "", "RequestType": 33024 }, //查询读写器固件最新版本（8100）
    {"UptIp": "", "UptPort": 0, "ChipType": 255, "ReqVer": "", "AppSize": 0, "SHA1": "", "FileName": "", "RFU": "", "RequestType": 33025 }, //更新指令1（8101）
    {"RFU": "", "RequestType": 33026 }, //更新指令2（8102）
    {"RFU": "", "RequestType": 33027},//更新指令3（8103）
    {"TransAmt":0,"CAIC":"","TN":"","CATI":"","PIN":"","AccNo":"","PinCheckAmt":0,"BalNotice":0,"SCMA":0,"SRMA":0,"DMCN":0,"DMRN":0,"DMCCA":0,"DMRCA":0,"RFU":"","RequestType":29701},//修改帐户信息
    {"TransAmt":0,"CAIC":"","TN":"","CATI":"","PIN":"","RFU":"","RequestType":29765},//客户登录
    {"TransAmt":0,"CAIC":"","TN":"","CATI":"","PIN":"","AccNo":"","ClientType":"","ClientName":"","IdType":"","IdNo":"","ClientRank":"","Phone":"","Email":"","LoginName":"","NickName":"","LoginPwd":"","Sex":"","HomePhone":"","OfficePhone":"","OtherPhone":"","Addr1":"","Postcode1":"","Addr2":"","Postcode2":"","ClientStatus":"0","RequestType":29781}//修改客户信息
];
/**
 * 获取json数据模板
 * @param req 接口类型
 * @returns 返回json数据模板
 */
function getEcardToneJson(req) {
    var e = null;
    for (var i = 0; i < ecard.length; i++) {
        if (ecard[i].RequestType == req) {
            e = ecard[i];
            break;
        }
    }
    return e;
}
/**
 * 调用ActiveX
 * @param pCBFuncName 回调函数名称  
 * @param pJson Json数据
 */
function MiugoActiveXExc(pCBFuncName,pJson){
	var miguoActiveX = document.getElementById("Miugo");
	if(miguoActiveX != null){
		//miguoActiveX.CallbackFunc = pCBFuncName;
		miguoActiveX.RegCallback(pCBFuncName);
		miguoActiveX.Trade(pJson);
	}
}




/**
 * 判断是否为空
 * @param pStr  要检查的数据
 * @returns {Boolean} 返回是否为空
 */
function IsEmpty(pStr){
    return ((pStr==null) || (pStr.length==0) );
} 
/**
 * 判断字符串是不是数字（可以为负数，小数）
 * @param str
 * @returns 返回判断结果
 */
function IsNumber(pStr)
{
    if (IsEmpty(pStr))
        return true;
    if (isNaN(pStr))
        return false;
    return true; 
} 
/**
 * 格式化字符串，向左补0
 * @param str 
 * @param lenght
 * @returns
 */
function PadLeftZero(str, lenght) {
    if (str.length >= lenght)
        return str;
    else
        return PadLeftZero("0" + str,lenght);
}

/**
 *验证身份证号
 *@param cardId
 *@returns 返回判断结果
 */
 function isCardId(cardId){
  	var aCity={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"};
	var iSum=0 ;
	if(!/^\d{17}(\d|x)$/i.test(cardId)) return false; 
	cardId=cardId.replace(/x$/i,"a"); 
	if(aCity[parseInt(cardId.substr(0,2))]==null) return false; 
	sBirthday=cardId.substr(6,4)+"-"+Number(cardId.substr(10,2))+"-"+Number(cardId.substr(12,2)); 
	var d=new Date(sBirthday.replace(/-/g,"/")) ;
	if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))return false; 
	for(var i = 17;i>=0;i--) iSum += (Math.pow(2,i) % 11) * parseInt(cardId.charAt(17 - i),11) ;
	if(iSum%11!=1) return false; 
	return true;//aCity[parseInt(sId.substr(0,2))]+","+sBirthday+","+(sId.substr(16,1)%2?"男":"女") 
}

/**
 *验证身份证号
 *@param className
 *@returns 返回判断结果
 */
 function isClassName(className){
 	var cuowu="rerror";
 	if(cuowu==className) return true;
 	return false;
 }
 
//说明 ：用 Javascript 实现锚点(Anchor)间平滑跳转 
 // 转换为数字
 function intval(v)
 {    
	 v = parseInt(v);    
	 return isNaN(v) ? 0 : v;
 } 
 // 获取元素信息
function getPos(e)
{    
	var l = 0;    
	var t  = 0;    
	var w = intval(e.style.width);    
	var h = intval(e.style.height);    
	var wb = e.offsetWidth;    
	var hb = e.offsetHeight;    
	while (e.offsetParent)
	{       
		l += e.offsetLeft + (e.currentStyle?intval(e.currentStyle.borderLeftWidth):0);        
		t += e.offsetTop  + (e.currentStyle?intval(e.currentStyle.borderTopWidth):0);        
		e = e.offsetParent;    
	}    
	l += e.offsetLeft + (e.currentStyle?intval(e.currentStyle.borderLeftWidth):0);    
	t  += e.offsetTop  + (e.currentStyle?intval(e.currentStyle.borderTopWidth):0);    
	return {x:l, y:t, w:w, h:h, wb:wb, hb:hb}; 
 } 
 // 获取滚动条信息
 function getScroll() 
 {    
	 var t=0, l=0, w=0, h=0;	 
	 if (document.documentElement && document.documentElement.scrollTop)
	 {        
		 t = document.documentElement.scrollTop;        
		 l = document.documentElement.scrollLeft;        
		 w = document.documentElement.scrollWidth;       
		 h = document.documentElement.scrollHeight;    
	 }
	 else if (document.body)
	 {        
		 t = document.body.scrollTop;        
		 l = document.body.scrollLeft;        
		 w = document.body.scrollWidth;        
		 h = document.body.scrollHeight;    
	 }    
	 return { t: t, l: l, w: w, h: h };
  } 
 // 锚点(Anchor)间平滑跳转
 function GoAnchor(el, duration)
 {    
	 /*if(typeof el != 'object')
	 {
		 el = document.getElementById(el);
	 }     
	 if(!el) return;*/   
	 
	 location.hash = el;
	 return;
	 
	 var z = this;    
	 z.el = el;    
	 z.p = getPos(el);    
	 z.s = getScroll();    
	 z.clear = function()
	 {
		 window.clearInterval(z.timer);z.timer=null;
	 };    
	 z.t=(new Date).getTime();     
	 z.step = function()
	 {        
		 var t = (new Date).getTime();        
		 var p = (t - z.t) / duration;        
		 if (t >= duration + z.t)
		 {            
			 z.clear();            
			 window.setTimeout(function(){z.scroll(z.p.y, z.p.x);},13);         
		 }
		 else {            
			 st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.y-z.s.t) + z.s.t;            
			 sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.x-z.s.l) + z.s.l;            
			 z.scroll(st, sl);        
		 }    
	 };    
	 z.scroll = function (t, l){window.scrollTo(l, t);};    
	 z.timer = window.setInterval(function(){z.step();},13);
  }
 
 
 	/**
	 * 只能输入正整数
	 */
	function TextOnlyNum(e,pPageSize)
	{
		// 响应回车
     var key = window.event ? e.keyCode : e.which;
		if(!((key >= 48 && key <= 57)||(key >= 96 && key <= 105)||(key == 8))){
			e.returnValue=false;
			if(e.keyCode == 13){
				RespontEnter(10);
			}
		} 
	} 
	//相应页面输入，按回车
	function RespontEnter(pPageSize){
		var pagecount = parseInt(document.getElementById("h_pagecount").value);
		var pageindex = parseInt(document.getElementById("h_pageindex").value);
		if( pagecount > 0){
			//获取页数
			var currentpage = parseInt(document.getElementById("t_currentpage").value);
			//等于当前页
			if(currentpage == pageindex){
				document.getElementById("t_currentpage").value = pageindex;
				currentpage = pageindex;
				return;
			}
			//如果是0则改成1
			if(currentpage == 0){
				document.getElementById("t_currentpage").value = 1;
				currentpage = 1;
			}
			//最大页数
			if(currentpage >= pagecount){
				document.getElementById("t_currentpage").value = pagecount;
				currentpage = pagecount;
			}
			GoPage(currentpage,pPageSize);
		}else{
			document.getElementById("t_currentpage").value = 1;
		}
	}
	//将分转换为元
	function FenToYuan(pFen){
		if(IsEmpty(pFen)){
			return "";
		}
		var fen = parseInt(pFen);
		var yuan = fen/100;
		return toDecimal2(yuan);
	}
	
	//制保留2位小数，如：2，会在2后面补上00.即2.00  
    function toDecimal2(x) {  
        var f = parseFloat(x);  
        if (isNaN(f)) {  
            return false;  
        }  
        var f = Math.round(x*100)/100;  
        var s = f.toString();  
        var rs = s.indexOf('.');  
        if (rs < 0) {  
            rs = s.length;  
            s += '.';  
        }  
        while (s.length <= rs + 2) {  
            s += '0';  
        }  
        return s;  
    } 
 
	
	
	
	
	
	
	
	
	
	
	
	
	
	
